Skip to content

Remove jsg::Name - #8212

Merged
jasnell merged 2 commits into
mainfrom
biwanczuk/remove-jsg-name
Nov 4, 2026
Merged

jasnell merged 2 commits into
mainfrom
biwanczuk/remove-jsg-name

Conversation

@bartlomieju

Copy link
Copy Markdown
Collaborator

Remove jsg::Name

jsg::Name held either a string or a v8::Symbol. It had two consumers in C++, and neither
needed it. This PR moves both to existing types and deletes Name, NameWrapper, and the
Lock::newSymbol(), newSharedSymbol() and newApiSymbol() helpers.

Changes

  • UtilModule::getResourceTypeInspect() returns jsg::JsSymbol from js.symbolInternal() in
    place of jsg::Name from js.newApiSymbol().
  • DiagnosticsChannelModule::publishToTracer() builds the channel-name kj::String directly.
    It no longer builds a jsg::Name and calls toString() on it.
  • Deleted: Name (jsg.h/jsg.c++), NameWrapper (value.h) and its TypeWrapper registration,
    the jsg::Name RTTI mapping (rtti.h), the Lock::new*Symbol() helpers, the value-test.c++
    cases, and the docs in jsg/README.md and docs/jsg.md.

Why this is safe

Nothing else uses it. After this change, src/ has no references to jsg::Name,
NameWrapper or Lock::new*Symbol(). The only callers of new*Symbol() outside
getResourceTypeInspect() were in value-test.c++. Rust JSG has its own v8::Name marker type
and never used the C++ class. The internal repo doesn't use jsg::Name or newApiSymbol either.

kResourceTypeInspect is the same symbol. newApiSymbol(s) was
v8::Symbol::ForApi(isolate, v8StrIntern(isolate, s)), and Lock::symbolInternal(s) is the same
expression. For a symbol, NameWrapper::wrap() returned the handle unchanged, and so does wrapping
a JsSymbol. The property is still declared with JSG_READONLY_INSTANCE_PROPERTY, so its
attributes don't change either. internal_inspect.ts, internal_mime.ts and messagechannel.ts,
which look the symbol up with getApiSymbol('kResourceTypeInspect'), still get the same symbol.

The tracer channel name is the same string. The new code uses the expressions from
Name::toString():

  • A string name: before, Name(nameValue.toString(js)) stored the string and toString()
    returned a copy of it. Now the code uses nameValue.toString(js) directly.
  • A symbol name: before and after, the string is
    kj::str("Symbol(", symbol->Description(isolate), ")").

A symbol without a description is formatted the same way as before, because the same
Description() handle goes through the same kj::str stringification. Both the normal path and
the fallback path for unserializable messages send this string.

TypeScript output doesn't change. No public API took or returned jsg::Name;
UtilModule is internal (node-internal:util). just generate-types leaves
types/generated-snapshot/ unchanged.

The RTTI schema is unchanged. JSG_NAME stays in the JsgImplType enum in rtti.capnp,
because removing it would shift the numbers of the values after it. The types/ generator keeps
its JSG_NAME case: its switch ends with an exhaustive satisfies never check, so the case
has to stay for as long as the enum value exists. C++ no longer produces this value.

jsg::Name had two consumers, neither of which needed it:

- UtilModule::getResourceTypeInspect() now returns a jsg::JsSymbol from
  js.symbolInternal(), which, like the removed Lock::newApiSymbol(), is
  v8::Symbol::ForApi(). JS sees the same Symbol.forApi("kResourceTypeInspect")
  symbol as before.
- DiagnosticsChannelModule::publishToTracer() built a jsg::Name only to call
  toString() on it. It now computes the string directly with the same
  expressions: strings pass through unchanged and symbols become
  "Symbol(<description>)", so the tracer gets the same channel-name string.

Lock::newSymbol(), newSharedSymbol() and newApiSymbol() returned Name and
duplicated Lock::symbol(), symbolShared() and symbolInternal(), so they are
removed too. NameWrapper, its TypeWrapper registration, the RTTI mapping, its
value-test cases and its documentation go with it. The JSG_NAME value stays in
the rtti.capnp JsgImplType enum, because removing an enumerant would renumber
the rest.

No behaviour changes; the generated type snapshot is unchanged.
@bartlomieju
bartlomieju requested review from a team as code owners November 4, 2026 11:27

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 2ba1df92.

This review, of 33ab9d42

✅ Approved — A clean removal: both callers keep the same behaviour, and none of the changed lines has a problem.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md updates needed.


📋 Code Quality: ✅ LGTM

Both replacement call sites keep the same behaviour, and no references to the removed types are left under src/.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

The Name docs were removed from docs/jsg.md and src/workerd/jsg/README.md, as they should be.


Reviewed commit: 33ab9d42

@codecov-commenter

codecov-commenter commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.79%. Comparing base (2a82c55) to head (2ba1df9).

Files with missing lines Patch % Lines
src/workerd/api/node/diagnostics-channel.c++ 60.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8212   +/-   ##
=======================================
  Coverage   68.79%   68.79%           
=======================================
  Files         743      743           
  Lines      194673   194576   -97     
  Branches    30171    30151   -20     
=======================================
- Hits       133925   133863   -62     
+ Misses      43043    43018   -25     
+ Partials    17705    17695   -10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — A clean removal: both callers keep the same behaviour, and none of the changed lines has a problem.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md updates needed.


📋 Code Quality: ✅ LGTM

Both replacement call sites keep the same behaviour, and no references to the removed types are left under src/.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

The Name docs were removed from docs/jsg.md and src/workerd/jsg/README.md, as they should be.


Reviewed commit: 2ba1df92 — same changes as 33ab9d42, so this is that commit's review (no new review was run; line numbers are as of 33ab9d42)

@jasnell
jasnell enabled auto-merge November 4, 2026 18:20
@jasnell
jasnell merged commit 383a4bb into main Nov 4, 2026
23 of 25 checks passed
@jasnell
jasnell deleted the biwanczuk/remove-jsg-name branch November 4, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants